package org.liulinlin.sejw.db;

import java.sql.*;

public class ShipperNote {
	private String id;
	private Date initDate;
	private String initDateString;
	private Date dateOfExpiry;
	private String dateOfExpiryString;
	private SNStatus snStatus;
	private AllocDetails allocDetails;
	private BLInfo blInfo;
	
	public ShipperNote() {
		
	}
	public ShipperNote(String id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("ShipperNote不能获得数据库连接");
			return;
		}
		
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery("select * from ShipperNote where SN_ID = '" + id + "'");
		
			rs.next();
			this.id = id;
			initDate = rs.getDate("SN_InitDate");
			initDateString = initDate.toString();
			dateOfExpiry = rs.getDate("SN_DateOfExpiry");
			dateOfExpiryString = dateOfExpiry.toString();
			snStatus = new SNStatus(rs.getInt("SNS_ID"));
			allocDetails = new AllocDetails(rs.getInt("AD_ID"));
			blInfo = new BLInfo(rs.getString("BL_ID"));
			
			stmt.close();
			rs.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		connMgr.release();
	}
	
	public void setId(String id) {
		this.id = id;
	}
	public void setInitDate(Date initDate) {
		this.initDate = initDate;
	}
	public void setInitDateString(String initDateString) {
		this.initDateString = initDateString;
	}
	public void setDateOfExpiry(Date dateOfExpiry) {
		this.dateOfExpiry = dateOfExpiry;
	}
	public void setDateOfExpiryString(String dateOfExpiryString) {
		this.dateOfExpiryString = dateOfExpiryString;
	}
	public void setSNStatus(SNStatus snStatus) {
		this.snStatus = snStatus;
	}
	public void setAllocDetails(AllocDetails allocDetails) {
		this.allocDetails = allocDetails;
	}
	public void setBLInfo(BLInfo blInfo) {
		this.blInfo = blInfo;
	}
	
	public String getId() {
		return id;
	}
	public Date getInitDate() {
		return initDate;
	}
	public String getInitDateString() {
		return initDateString;
	}
	public Date getDateOfExpiry() {
		return dateOfExpiry;
	}
	public String getDateOfExpiryString() {
		return dateOfExpiryString;
	}
	public SNStatus getSNStatus() {
		return snStatus;
	}
	public AllocDetails getAllocDetails() {
		return allocDetails;
	}
	public BLInfo getBLInfo() {
		return blInfo;
	}
}
